/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nokia.iap.example.onebutton;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.*;
import nokia.iap.ui.lib.onebutton.IAPCompletionListener;
import nokia.iap.ui.lib.onebutton.OneButtonIAP;

/**
 * @author zinin
 */
public class OneButtonMidlet extends MIDlet implements CommandListener, IAPCompletionListener{
    public static final String productID = "588547";
    public static final String DRM_PATH = "drm/data/resourceid_";
    public static final String lockedFname = "data.txt";

    private OneButtonIAP canvas;
    public static final Command exitCommand = new Command( "Exit", Command.EXIT, 1 ); 

    public void startApp() {
        canvas = new OneButtonIAP(this, productID, lockedFname);
        try {
            // full touch device detected
            com.nokia.mid.ui.VirtualKeyboard.hideOpenKeypadCommand(true);
        } catch (Throwable e) {
        }
        Display.getDisplay(this).setCurrent(canvas);
    }
    
    public void pauseApp() {
    }
   
    public void destroyApp(boolean unconditional) {
        exitMIDlet();
    }

    public void exitMIDlet(){
        notifyDestroyed();
    }

    public void commandAction(Command c, Displayable d) {
        if( c == exitCommand ){
            exitMIDlet();
        }
    }

    public void notifyIAPComplete(boolean bln) {
        exitMIDlet();
    }

    public Display clientDisplay() {
        return Display.getDisplay(this);
    }
}
